class Solution {
public:
    int s[1000]={0};
    string multiply(string num1, string num2) {
        memset(s, 0, sizeof(s));
        reverse(num1.begin(), num1.end());
        reverse(num2.begin(), num2.end());
        int sum=0;
        for (int i = 0; i < num2.size(); i++)
        {
            int t = 0;
            int p = i;
            for (int j = 0; j < num1.size(); j++)
            {
                int a = num2[i] - '0';
                int b = num1[j] - '0';
                a *= b;
                a += t;
                s[p] += (a % 10);
                t = a / 10;
                if (s[p] >= 10) {
                    s[p] -= 10;
                    t += 1;
                }
                ++p;
            }
            sum = p - 1;
            if (t) {
                s[p] = t;
                sum = p;
            }
        }
        string result;
        for(int i=0;i<=sum;i++){
            result+=('0'+s[i]);
        }
        while(result.size()>1&&result.back()=='0'){
            result.pop_back();
        }
        reverse(result.begin(),result.end());
        return result;
    }
};